<?php echo $this->Html->script('jquery.MultiFile.pack', array('inline' => false));?>

<?php echo $this->Form->create('Equipamento', array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'));?>
<div class="page">
	<div class="page-header">
		<div class="pull-left">
			<i class="icon-awesome-file-alt icon-large"></i>
			<span class="divider"></span>
			<div class="title">
				<h3><?php echo __('Equipamentos');?></h3>
				<small><?php echo __('Adicionar novo equipamento');?></small>
			</div>
		</div>
		<div class="pull-right">
			<?php echo $this->Form->button('<i class="icon-awesome-save icon-white"></i>' . __('Salvar'), array('type' => 'submit', 'escape' => false, 'class' => 'btn btn-primary btn-square')); ?>
			<?php echo $this->Html->link('<i class="icon-awesome-undo icon-white"></i>' . __('Voltar'), array('action' => 'index'), array('escape' => false, 'class' => 'btn btn-square')); ?>
		</div>
	</div>
	<div class="page-content">
			<fieldset>
				<legend><?php echo __('Novo Equipamento'); ?></legend>
				<div class="control-group <?php echo ($this->Form->isFieldError('categoria_id')) ? 'error' : ''; ?>">
					<?php echo $this->Form->Label('categoria_id', 'Categoria', array('class' => 'control-label'));	?>
					<div class="controls">
						<?php echo $this->Form->input('categoria_id', array('options' => $categorias, 'empty' => true, 'label' => false, 'div' => false, 'class' => 'span6', 'error' => false));	?>
						<?php echo $this->Form->error('categoria_id', null, array('wrap' => 'p', 'class' => 'help-block')); ?>
					</div>
				</div>
				<div class="control-group <?php echo ($this->Form->isFieldError('descricao')) ? 'error' : ''; ?>">
					<?php echo $this->Form->Label('descricao', 'Descrição', array('class' => 'control-label'));	?>
					<div class="controls">
						<?php echo $this->Form->input('descricao', array('type' => 'textarea', 'rows' => 3, 'label' => false, 'div' => false, 'class' => 'span10', 'error' => false)); ?>
						<?php echo $this->Form->error('descricao', null, array('wrap' => 'p', 'class' => 'help-block')); ?>
					</div>
				</div>
				<div class="control-group <?php echo ($this->Form->isFieldError('numero_serie')) ? 'error' : ''; ?>">
					<?php echo $this->Form->Label('numero_serie', 'Número de Série', array('class' => 'control-label'));	?>
					<div class="controls">
						<?php echo $this->Form->input('numero_serie', array('type' => 'text', 'label' => false, 'div' => false, 'class' => 'span6', 'error' => false)); ?>
						<?php echo $this->Form->error('numero_serie', null, array('wrap' => 'p', 'class' => 'help-block')); ?>
					</div>
				</div>
				<div class="control-group <?php echo ($this->Form->isFieldError('tombo')) ? 'error' : ''; ?>">
					<?php echo $this->Form->Label('tombo', 'Tombo', array('class' => 'control-label'));	?>
					<div class="controls">
						<?php echo $this->Form->input('tombo', array('type' => 'text', 'label' => false, 'div' => false, 'class' => 'span6', 'error' => false)); ?>
						<?php echo $this->Form->error('tombo', null, array('wrap' => 'p', 'class' => 'help-block')); ?>
					</div>
				</div>
				<div class="control-group <?php echo ($this->Form->isFieldError('localizacao_id')) ? 'error' : ''; ?>">
					<?php echo $this->Form->Label('localizacao_id', 'Localização', array('class' => 'control-label'));	?>
					<div class="controls">
						<?php echo $this->Form->input('localizacao_id', array('options' => $localizacaos, 'empty' => true, 'label' => false, 'div' => false, 'class' => 'span6', 'error' => false));	?>
						<?php echo $this->Form->error('localizacao_id', null, array('wrap' => 'p', 'class' => 'help-block')); ?>
					</div>
				</div>
				<div class="control-group <?php echo ($this->Form->isFieldError('projeto_id')) ? 'error' : ''; ?>">
					<?php echo $this->Form->Label('projeto_id', 'Projeto', array('class' => 'control-label'));	?>
					<div class="controls">
						<?php echo $this->Form->input('projeto_id', array('options' => $projetos, 'empty' => true, 'label' => false, 'div' => false, 'class' => 'span6', 'error' => false));	?>
						<?php echo $this->Form->error('projeto_id', null, array('wrap' => 'p', 'class' => 'help-block')); ?>
					</div>
				</div>
				<div class="control-group">
					<?php echo $this->Form->Label('anexo', 'Imagens', array('class' => 'control-label'));?>						
					<div class="controls">
						<?php 
						echo $this->Form->input('anexo', array(
							'label' => false, 
							'name' => 'data[Equipamento][anexo][]',
							'type' => 'file', 
							'div' => array('style'=>'margin-left: -75px; margin-right') )); 
						?>
						<div id="lista_anexos" style="text-align: left; border: 1px; padding-left: 90px;"></div>						
					</div>
				</div>
				<div class="control-group <?php echo ($this->Form->isFieldError('quantidade')) ? 'error' : ''; ?>">
					<?php echo $this->Form->Label('quantidade', 'Quantidade', array('class' => 'control-label'));	?>
					<div class="controls">
						<?php echo $this->Form->input('quantidade', array('type' => 'number', 'value'=>'1','label' => false, 'div' => false, 'class' => 'span6', 'error' => false)); ?>
						<?php echo $this->Form->error('quantidade', null, array('wrap' => 'p', 'class' => 'help-block')); ?>
					</div>
				</div>
			</fieldset>
	</div>
</div>
<?php echo $this->Form->end();?>

<script>
$(document).ready(function(){
	$('#EquipamentoAnexo').MultiFile({
		STRING: {
			remove: '<?php echo $this->Html->image('delete.png');?>',
			denied:'Tipo de arquivo inválido:  $ext. \n Arquivo deve ser Imagem, Documento ou Compactado'
			},
		accept: 'jpg|jpeg|gif|png|bmp|tiff',
		list: '#lista_anexos'			
	});
});
</script>